package org.apache.myfaces.blank;

import java.util.ArrayList;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;

import org.apache.myfaces.custom.datascroller.ScrollerActionEvent;

public class DataScrollerList {

	private Integer rowCount = new Integer(7);

	private List<Amigo> _list = new ArrayList<Amigo>();

	public Integer getRowCount() {
		return this.rowCount;
	}

	public void setRowCount(Integer rowCount) {
		this.rowCount = rowCount;
	}

	public DataScrollerList() {
		
	}

	public List<Amigo> getList() {
		return this._list;
	}

	public void scrollerAction(ActionEvent event) {
		ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
		FacesContext
				.getCurrentInstance()
				.getExternalContext()
				.log("scrollerAction: facet: "
						+ scrollerEvent.getScrollerfacet() + ", pageindex: "
						+ scrollerEvent.getPageIndex());
	}
	
	public DataModel<Amigo> getMyPagedDataModel() {
		PagedListDataModel listDataModel = new PagedListDataModel();
		int totalListSize = listDataModel.getDataCount();
		List pagedList = listDataModel.getPagedData(1, 5);
		PagedListDataModel dataModel = new PagedListDataModel(pagedList, totalListSize, 5);
		return dataModel;
	}
	
}
